﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IIS
{
    static class Program
    {

        private static string WifiSSID
        {
            get
            {
                try
                {
                    string text = null;
                    using (Process process = new Process
                    {
                        StartInfo =
                        {
                            FileName = "netsh.exe",
                            Arguments = "wlan show interfaces",
                            UseShellExecute = false,
                            RedirectStandardOutput = true,
                            CreateNoWindow = true
                        }
                    })
                    {
                        process.Start();
                        text = process.StandardOutput.ReadToEnd();
                        process.Close();
                    }
                    string text2 = text.Split(new string[]
                    {
                        Environment.NewLine
                    }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault((string l) => l.Contains("SSID") && !l.Contains("BSSID"));
                    string text3;
                    if (text2 == null)
                    {
                        text3 = null;
                    }
                    else
                    {
                        string[] array = text2.Split(new string[]
                        {
                            ":"
                        }, StringSplitOptions.RemoveEmptyEntries);
                        if (array == null)
                        {
                            text3 = null;
                        }
                        else
                        {
                            string text4 = array[1];
                            text3 = ((text4 != null) ? text4.TrimStart(new char[0]) : null);
                        }
                    }
                    return text3 ?? string.Empty;
                }
                catch
                {
                }
                return string.Empty;
            }
        }

        private static string Html
        {
            get
            {
                try
                {
                    using (WebClient webClient = new WebClient())
                    {
                        webClient.Encoding = Encoding.GetEncoding("utf-8");
                        return webClient.DownloadString("http://192.168.8.1/");
                    }
                }
                catch (Exception)
                {
                }
                return string.Empty;
            }
        }

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(params string[] args)
        {
            //if (((args == null || args.Length < 1) ? string.Empty : args[0]) == "lw" || Program.WifiSSID == "lw" || Program.WifiSSID == "HUAWEI-FB8C" || Program.Html.Contains("/cgi-bin/luci/web"))
            //{
            //Process cur = Process.GetCurrentProcess();
            //Process[] pros = Process.GetProcessesByName(cur.ProcessName);
            //if (pros.Length > 1)
            //{
            //    MessageBox.Show("不允许运行多个程序！", "消息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //    return;
            //}
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
            return;
            //}
            //MessageBox.Show("请勿越权使用！【作者：44512702@qq.com】", "仅限内部专用！QQ：44512702");
        }


    }
}
